Skip to content

Generate configuration parameters overview - #5932

Draft
mpkorstanje wants to merge 62 commits into
mainfrom
feature/generate-configuration-parameters-overview
Draft

Generate configuration parameters overview #5932
mpkorstanje wants to merge 62 commits into
mainfrom
feature/generate-configuration-parameters-overview

Conversation

@mpkorstanje

@mpkorstanje mpkorstanje commented Jul 30, 2026

Copy link
Copy Markdown
Member

Generate META-INF/junit-platform-configuration-metadata.json in the format of Spring Boots Configuration Metadata.

Minimal example

The minimal usage:

/**
 * A brief multi-line description of
 * this property: {@value}.
 *
 * <p>Followed by an additional paragraph.
 */
@ConfigurationProperty
public static final String EXAMPLE_PROPERTY_NAME = "org.example.property";

Produces:

{
  "properties": [
	{
	  "name": "org.example.property",
      "description": "A brief multi-line description of this property.",
	  "sourceType": "com.example.app.Constants"
	}
  ]
}

This takes all the information from the obvious places. Of note is that the first paragraph from the doc string is used and the : {@value}. that we conventionally use is replaced with a ..

Deprecation

@Deprecated
@ConfigurationParameter
public static final String EXAMPLE_PROPERTY_NAME = "org.example.property";

Produces:

{
  "properties": [
	{
	  "name": "org.example.property",
      "description": "A brief multi-line description of this property.",
	  "sourceType": "com.example.app.Constants",
      "deprecated": { }
	}
  ]
}

The empty deprecated object is sufficient to mark a field as deprecated. To fill out the fields in the deprecated object the @Deprecation annotation can be used:

@Deprecated
@ConfigurationParameter(deprecation = @Deprecation(reason = "A an example reason", replacement = "com.example.app.Constants#EXAMPLE_PROPERTY_NAME_V2", since = "2.0.0"))
public static final String EXAMPLE_PROPERTY_NAME_V1 = "org.example.property";

Type and default

The type of the parameter can be provided using the type property of the annotation.

@ConfigurationParameter(type = String.class)
public static final String EXAMPLE_PROPERTY_NAME = "org.example.property";

Though in practice this will be rarely needed. If the type is not provided, we can take the type of the default value.

@ConfigurationParameter(defaultValue = @Value(stringValue = "default"))
public static final String EXAMPLE_PROPERTY_NAME = "org.example.property";

When using Enums it is useful to use both type and default value, because arbitrary enums can't be used in an annotation.

@ConfigurationParameter(defaultValue = @Value(intValue = 42))
public static final String INTS_PROPERTY_NAME = "org.example.ints";

Limitations

  • Metadata.groups, Metadata.hints, Metadata.ignored are not yet implemented. They might be useful later on, but we don't need them yet.
  • While Property.default supports lists of values, the implementation is intentionally limited to a single value.

Closes: #4330


I hereby agree to the terms of the JUnit Contributor License Agreement.


Definition of Done

@mpkorstanje
mpkorstanje force-pushed the feature/generate-configuration-parameters-overview branch from c73e0df to 14ffed5 Compare July 30, 2026 21:38
@mpkorstanje
mpkorstanje force-pushed the feature/generate-configuration-parameters-overview branch from f02ff2f to 3295a99 Compare July 30, 2026 22:58
Comment thread junit-platform-configuration-api/junit-platform-configuration-api.gradle.kts Outdated
Comment thread junit-jupiter-api/junit-jupiter-api.gradle.kts
Comment thread junit-jupiter-migrationsupport/junit-jupiter-migrationsupport.gradle.kts Outdated
@mpkorstanje
mpkorstanje force-pushed the feature/generate-configuration-parameters-overview branch 2 times, most recently from 6c063a1 to e6ab635 Compare July 31, 2026 08:52
@mpkorstanje
mpkorstanje force-pushed the feature/generate-configuration-parameters-overview branch from e6ab635 to 314e8fd Compare July 31, 2026 09:57
* <p>The default behavior is not to perform auto-detection.
*/
// TODO: Handle @link references.
@ConfigurationParameter(defaultValue = @Value(booleanValue = false))

@mpkorstanje mpkorstanje Aug 10, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marcphilipp to keep the documentation and implementation consistent I think it would help to extract all the default values to constants and use them when parsing configuration parameters. Thoughts?

* <p>Value must be a positive decimal number; defaults to {@code 1}.
*
*/
@ConfigurationParameter(type = BigDecimal.class, defaultValue = @Value(doubleValue = 1.0))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need infinite precision here?

* @see Timeout#DEFAULT_TIMEOUT_PROPERTY_NAME
*/
// TODO: TimeoutDuration is not part of the public API
@ConfigurationParameter /*(type = TimeoutDuration.class)*/

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this yet. We could use a string here, but TimeoutDuration has a specific format.

TODO: Investigate how this works with Duration in Spring.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String plus a regex?

@mpkorstanje
mpkorstanje force-pushed the feature/generate-configuration-parameters-overview branch from c7753c0 to dc9a43a Compare August 11, 2026 03:12
@testlens-app

testlens-app Bot commented Aug 11, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 98f0885
▶️ Tests: 34041 executed
⚪️ Checks: 17/17 completed


Learn more about TestLens at testlens.app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Configuration Parameters Overview

2 participants